import Vue from 'vue'
import Router from 'vue-router'
const Home = () =>
    import ('../views/Home/Home.vue');
const Mall = () =>
    import ('../views/Mall/Mall.vue');
const Goods = () =>
    import ('../views/Mall/Detail/Goods.vue');
const ShopCart = () =>
    import ('../views/Mall/ShopCart/ShopCart.vue');
const Release = () =>
    import ('../views/Mall/GoodRelease.vue')
const Square = () =>
    import ('../views/Square/Square.vue');
const Music = () =>
    import ('../views/Music/Music.vue');
const Chat = () =>
    import ('../views/Chat/Chat.vue');
const PublicChat = () =>
    import ('../views/Chat/Conversation/public/PublicChat.vue');
const PrivateChat = () =>
    import ('../views/Chat/Conversation/private/PrivateChat.vue')
const Profile = () =>
    import ('../views/Profile/Profile.vue');
const ProfileEdit = () =>
    import ('../views/Profile/ProfileEdit.vue')
const Space = () =>
    import ('../views/Profile/space/Space.vue');
const Collection = () =>
    import ('../views/Profile/collection/Collection.vue')
const Song = () =>
    import ('../views/Song/Song.vue');
const SquarePost = () =>
    import ('../views/Square/SquarePost.vue');
const CommentDetail = () =>
    import ('../views/Square/Detail/CommentDetail.vue')
const UserReg = () =>
    import ('../views/User/UserReg.vue')
const UserLog = () =>
    import ('../views/User/UserLogin.vue');
const UserIndex = () =>
    import ('../views/User/UserIndex.vue')
Vue.use(Router);

export default new Router({
    routes: [
        //home主页路由
        {
            path: '/',
            redirect: '/home'
        }, {
            path: '/home',
            component: Home
        },
        //mall商城路由
        {
            path: '/mall',
            component: Mall
        },
        {
            path: '/good/:gid',
            name: 'Good',
            component: Goods
        }, {
            path: '/release',
            component: Release
        }, {
            path: '/shopcart',
            component: ShopCart,
        },
        //广场路由
        {
            path: '/square',
            component: Square
        }, {
            path: '/square_post',
            component: SquarePost
        }, {
            path: '/comment_detail/:cid',
            name: 'Comment',
            component: CommentDetail
        },
        //音乐路由
        {
            path: '/music',
            component: Music,
        },
        //用户路由
        {
            path: '/profile',
            component: Profile
        }, {
            path: '/user_edit',
            component: ProfileEdit
        }, {
            path: '/reg',
            component: UserReg
        }, {
            path: '/login',
            component: UserLog
        }, {
            path: '/uindex/:uid',
            name: 'Uindex',
            component: UserIndex
        }, {
            path: '/space/:uid/:nickname',
            component: Space
        }, {
            path: '/collection',
            component: Collection
        },
        //聊天室路由
        {
            path: '/chat',
            component: Chat
        },
        {
            path: '/publicchat',
            component: PublicChat
        },
        {
            path: '/privatechat/:uid/:nickname',
            component: PrivateChat
        }
    ],
    mode: 'history'
})
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}